@section('breadcrumb')
<li class="active">订单管理</li>
@show

@section('content')


<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">添加订单</h3>
                
            </div><!-- /.box-header -->
            <form fole="form" method="post" action="{{ route('admin.order.add') }}" >
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <div class="box-body">
                <div class="form-group">
                    <label for="cat_title">标题</label>
                    <input type="text" name="data[title]" id="cat_title" placeholder="标题" value="" class="form-control"/>
                </div>
                
                <div class="form-group">
                    <label>商品</label>
                    <div  id="productListWrapper"></div>
                </div>
				<div style="clear:both;"></div>
				<div class="form-group">
                    <label for="member">用户</label>
					<div  id="memberListWrapper"></div>
                </div>
				
				<div style="clear:both;"></div>
                <div class="form-group">
                    <label for="cat_title">配送地址</label>
                    <div  id="memberAddrWrap"></div>
                </div>
                <div class="form-group">
                    <label for="sumprice">总价</label>
                    <input type="number" name="data[price]" >
                </div>
				<div class="form-group">
                    <label for="memo">备注</label>
                    <textarea name="data[memo]" class="form-control" rows="5" ></textarea>
                </div>	
                <div class="form-group">
                    <label for="upload_pic">订单状态</label>
                    <select name="work_node">
                    @foreach ( $works as $wnode)
                        <option value="{{ $wnode->id }}">{{ $wnode->name }}</option>
                    @endforeach
                    </select>
                </div>
					
				
                
            </div><!-- /.box-body -->
            <div class="box-footer">
                <button class="btn btn-primary" type="submit">Submit</button>
            </div>
				<input type="hidden" name="data[member_id]" id="hid_member_id" >
            </form>
        </div><!-- /.box -->
    </div>
</div>


@stop

@section('end')
    @parent
{{ HTML::script("/js/jquery-ui-1.11.1.min.js") }}

<script>
$(function() {
	$('#memberListWrapper').load("{{ route('admin.order.members') }}");
	$(document.body).on('click','#btnSearchMember', function(){
		var url = "{{ route('admin.order.members') }}?search_word=" + encodeURIComponent( $('#textSearchMember').val() );
		$('#memberListWrapper').load(url);
	});
	
	$(document.body).on('click','a.user-names', function(){
		var uid = $(this).attr('val');
		var url = "{{ route('admin.order.memaddr') }}?member_id="+uid;
		$('#hid_member_id').val(uid);
		$('#memberAddrWrap').load(url);
	});

	$('#productListWrapper').load("{{ route('admin.order.products') }}");
	$(document.body).on('click','#btnSearchProduct', function(){
		var url = "{{ route('admin.order.products') }}?search_word=" + encodeURIComponent( $('#textSearchProduct').val() );
		$('#productListWrapper').load(url);
	});
	$(document.body).on('click','input.pro-ids', function(){
		var row = $(this).parent().parent();
		if (this.checked) {
			row.find('td').eq(3).find('input').val('1');
		}else{
			row.find('td').eq(3).find('input').val('0');
		}
	});
});
</script>
@stop